<!-- 
   图文结构封装组件
  -->
<template>
  <div>
    <el-table :data="tableData" style="width: 100%" size="mini" border>
      <el-table-column type="index" width="50" label="序号" align="center">
      </el-table-column>
      <el-table-column
        label="公布日"
        prop="legalDatetime"
        align="center"
        width="150px;"
      >
        <template slot-scope="scope">
          <div>
            <el-date-picker
              v-model="scope.row.legalDatetime"
              style="width:130px;"
              size="mini"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="公布信息"
        prop="legalInfo"
        align="center"
        width="140px;"
      >
        <template slot-scope="scope">
          <div>
            <el-input
              v-model="scope.row.legalInfo"
              style="width:120px;"
              size="mini"
              maxlength="50"
            ></el-input>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="公布详细" prop="legalDesc" align="center">
        <template slot-scope="scope">
          <div>
            <el-input
              type="textarea"
              v-model="scope.row.legalDesc"
              placeholder="请输入内容"
              maxlength="500"
              show-word-limit
              resize="none"
              :autosize="{ minRows: 3 }"
            ></el-input>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="80px;">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="danger"
            plain
            style="margin: 5px"
            @click="del(scope.$index)"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="add-text">
      <span @click="addLine"><i class="el-icon-plus"></i>点击添加</span>
    </div>
  </div>
</template>
<script>
export default {
  name: "legalText",
  props: ["tableData"],
  data() {
    return {
      url: process.env.VUE_APP_URL + "/sys/oss/upload",
      // url: "https://jsonplaceholder.typicode.com/posts/"
      hideUpload: false,
      imgIndex: 0
    };
  },
  components: {},
  mounted() {},
  methods: {
    del(value) {
      this.tableData.splice(value, 1);
      this.$emit("handleTableDate", this.tableData);
    },
    addLine() {
      //添加行数
      var newValue = {
        legalDatetime: "",
        legalInfo: "",
        legalDesc: ""
      };
      //添加新的行数
      this.tableData.push(newValue);
      this.$emit("handleTableDate", this.tableData);
    }
  }
};
</script>
<style scoped lang="scss">
.sort {
  cursor: pointer;
  color: #409eff;
}
.sort:hover {
  color: #027cfb;
}
.add-text {
  text-align: center;
  span {
    cursor: pointer;
    color: #027cfb;
  }
}
</style>
